package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.common.AreaControlVO;
import com.jwsoft.manager.common.vo.eduCompany.EduCompanyKeyVO;
import com.jwsoft.manager.common.vo.eduCompany.EduCompanyQueryVO;
import com.jwsoft.manager.common.vo.eduCompany.EduCompanyVO;
import com.jwsoft.manager.common.vo.individuation.QySearchVO;
import com.jwsoft.manager.core.integration.EduCompanyIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 企业信息管理网关
 *
 * @author wangtao
 * @since 2022-12-28
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "企业信息管理", description = "企业信息管理")
public class EduCompanyController {

    @Autowired
    public EduCompanyIntegration eduCompanyIntegration;

    @Operation(summary = "企业信息管理分页查询",description = "企业信息管理分页查询")
    @PostMapping(value = "/EduCompany0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduCompanyVO>> getList(@RequestBody @Validated EduCompanyQueryVO vo) {
        return AppResponse.successData(eduCompanyIntegration.getList(vo));
    }

    @Operation(summary = "企业信息管理根据主键查询详情",description = "企业信息管理根据主键查询详情")
    @PostMapping(value = "/EduCompany0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduCompanyVO> getById(@RequestBody @Validated EduCompanyKeyVO vo) {
        return AppResponse.successData(eduCompanyIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "企业信息管理新增",description = "企业信息管理新增")
    @PostMapping(value = "/EduCompany0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduCompanyVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduCompanyVO vo) {
        return AppResponse.successData(eduCompanyIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "企业信息管理修改",description = "企业信息管理修改")
    @PostMapping(value = "/EduCompany0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduCompanyVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduCompanyVO vo) {
        return AppResponse.successData(eduCompanyIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "企业信息管理删除",description = "企业信息管理删除")
    @PostMapping(value = "/EduCompany0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduCompanyKeyVO vo) {
        eduCompanyIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Operation(summary = "获取企业信息",description = "获取企业信息")
    @PostMapping(value = "/EduCompany0008", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduCompanyVO>> getCompany(@RequestBody @Validated QySearchVO vo) {
        return AppResponse.successData(eduCompanyIntegration.getCompany(vo));
    }
    @Operation(summary = "家长端获取我的营业执照信息",description = "家长端获取我的营业执照信息")
    @PostMapping(value = "/EduCompany0009", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduCompanyVO>> getAppCompanyList(@RequestBody @Validated AreaControlVO vo) {
        return AppResponse.successData(eduCompanyIntegration.getAppCompanyList(vo));
    }
}
